package com.ruoyi.teacher.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.teacher.domain.SysProfession;
import com.ruoyi.teacher.domain.SysProfession;
import com.ruoyi.teacher.mapper.SysProfessionMapper;
import com.ruoyi.teacher.service.ISysProfessionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Validator;
import java.util.List;

/**
 * sysProfessionService业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@Service
public class SysProfessionServiceImpl implements ISysProfessionService
{
    private static final Logger log = LoggerFactory.getLogger(SysProfessionServiceImpl.class);
    @Autowired
    protected Validator validator;
    @Autowired
    private SysProfessionMapper sysProfessionMapper;

    /**
     * 查询sysProfession
     * 
     * @param id sysProfession主键
     * @return sysProfession
     */
    @Override
    public SysProfession selectSysProfessionById(Long id)
    {
        return sysProfessionMapper.selectSysProfessionById(id);
    }

    /**
     * 查询sysProfession列表
     * 
     * @param sysProfession sysProfession
     * @return sysProfession
     */
    @Override
    public List<SysProfession> selectSysProfessionList(SysProfession sysProfession)
    {
        return sysProfessionMapper.selectSysProfessionList(sysProfession);
    }

    /**
     * 新增sysProfession
     * 
     * @param sysProfession sysProfession
     * @return 结果
     */
    @Override
    public int insertSysProfession(SysProfession sysProfession)
    {
        return sysProfessionMapper.insertSysProfession(sysProfession);
    }

    /**
     * 修改sysProfession
     * 
     * @param sysProfession sysProfession
     * @return 结果
     */
    @Override
    public int updateSysProfession(SysProfession sysProfession)
    {
        return sysProfessionMapper.updateSysProfession(sysProfession);
    }

    /**
     * 批量删除sysProfession
     * 
     * @param ids 需要删除的sysProfession主键
     * @return 结果
     */
    @Override
    public int deleteSysProfessionByIds(String ids)
    {
        return sysProfessionMapper.deleteSysProfessionByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除sysProfession信息
     * 
     * @param id sysProfession主键
     * @return 结果
     */
    @Override
    public int deleteSysProfessionById(Long id)
    {
        return sysProfessionMapper.deleteSysProfessionById(id);
    }

    @Override
    public List<SysProfession> selectProfessionAll() {
        return sysProfessionMapper.selectProfessionAll();
    }

    @Override
    public List<SysProfession> selectProfessionsByProfessionId(Long professionId) {
        List<SysProfession> list =  selectProfessionAll();
        for(SysProfession sysProfession:list){
            if(sysProfession.getId()==professionId){
                sysProfession.setFlag(true);
                break;
            }
        }
        return list;
    }

}
